package com.xpresso.utils.props;

import java.io.ByteArrayInputStream;
import java.util.Properties;

public class PropertyWorker {

	public Properties getProperties(String propertiesString){
		if (propertiesString != null && !propertiesString.equals("")){
			Properties props = new Properties();
			byte[] bytes = propertiesString.getBytes();
		
			ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
			try {
				props.load(bais);
			} catch (Exception ex){
				// TODO: Log this exception AS ERROR.
			}	
			return props;
		} else {
			return null;
		}
	}
	
	public String getProperty(String propertiesString, String property){
		Properties props = this.getProperties(propertiesString);
		return props.getProperty(property);
	}
	
}
